//
//  StatisticsViewController.m
//  AssistantDriving
//
//  Created by dcr on 2017/9/5.
//  Copyright © 2017年 邓兆太. All rights reserved.
//

#import "StatisticsViewController.h"

@interface StatisticsViewController ()

@end

@implementation StatisticsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initWidgets];
}

- (void)initWidgets{
    // 数据
    NSArray *items = @[[PNPieChartDataItem dataItemWithValue:25 color:[UIColor colorWithRed:0.82 green:0.82 blue:0.82 alpha:1.00] description:@"未做题"],
                       [PNPieChartDataItem dataItemWithValue:25 color:[UIColor colorWithRed:0.00 green:0.73 blue:0.21 alpha:1.00] description:@"做对题"],
                       [PNPieChartDataItem dataItemWithValue:50 color:[UIColor colorWithRed:1.00 green:0.27 blue:0.33 alpha:1.00] description:@"做错题"],
                       ];
    // 初始化
    self.pieChart = [[PNPieChart alloc] initWithFrame:CGRectMake(MainScreenWidth /2.0 - 100, 90, 200.0, 200.0) items:items];
    self.pieChart.descriptionTextColor = [UIColor whiteColor];
    self.pieChart.descriptionTextFont  = [UIFont fontWithName:@"Avenir-Medium" size:11.0];
    self.pieChart.descriptionTextShadowColor = [UIColor clearColor]; // 阴影颜色
    self.pieChart.showAbsoluteValues = NO; // 显示实际数值(不显示比例数字)
    self.pieChart.showOnlyValues = YES; // 只显示数值不显示内容描述
    
    self.pieChart.innerCircleRadius = 0;
    //        self.pieChart.outerCircleRadius = 0;
    
    [self.pieChart strokeChart];
    
    UIView *legend = [[UIView alloc] initWithFrame:CGRectMake(0, 300, MainScreenWidth, 40)];
    int i = 0;
    for (PNPieChartDataItem *pdata in items) {
        UILabel *lable = [[UILabel alloc] init];
        lable.text = [pdata textDescription];
        lable.textColor = [pdata color];
        lable.font = WeekFont4;
        lable.textAlignment = NSTextAlignmentCenter;
        [legend addSubview:lable];
        CGFloat x = (MainScreenWidth/3.0)*i;
        [lable mas_makeConstraints:^(MASConstraintMaker *make){
            make.left.mas_equalTo(x);
            make.topMargin.mas_equalTo(0);
            make.size.mas_equalTo(CGSizeMake(MainScreenWidth/3.0, 40));
        }];
        i++;
    }
    [self.view addSubview:legend];
    [self.view addSubview:self.pieChart];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
